<template>
  <div class="home-page">
    <van-tabs>
      <van-tab :key="item.id" v-for="item in myChannels" :title="item.name">
        内容 {{ item.id }}
      </van-tab>
    </van-tabs>

    <!-- 按钮 -->
    <div class="btn-wrapper">
      <geek-icon name="search"></geek-icon>
      <geek-icon name="channel"></geek-icon>
    </div>
  </div>
</template>
<script>
// import GeekIcon from '@/components/geek-icon'
import { getMyChannels } from '@/api/channel'

export default {
  name: 'HomePage',
  data () {
    return {
      myChannels: []
    }
  },
  // components: { GeekIcon },
  async created () {
    // 不使用err不写err即可，但是,号需要写
    const [, res] = await getMyChannels()
    this.myChannels = res.data.data.channels
  }
}
</script>
<style scoped lang="less">
.home-page {
  .btn-wrapper {
    position: absolute;
    right: 0;
    top: 0;
    width: 86px;
    height: 44px;
    background: #fff;
    display: flex;
    align-items: center;
    .geek-icon {
      flex: 1;
      text-align: center;
      font-size: 18px;
    }
    &::before {
      content: '';
      width: 20px;
      height: 44px;
      position: absolute;
      left: -20px;
      top: 0;
      background: linear-gradient(to right, rgba(255, 255, 255, 0), #fff);
    }
  }
}
</style>
